Market closed error means that no trading is happening in the market at that time. You are executing the trading positions in the wrong trading hours.